<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

    <head th:include="include :: header"></head>
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/2.0.0-beta1/css/bootstrap-select.min.css" rel="stylesheet">
	<body class="gray-bg">
            <div class="wrapper wrapper-content animated fadeInRight">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>查看检测</h5>
                    </div>
                    <div class="ibox-content">
                        <form method="POST" action="/ttx/statistics/statisticsTable" onsubmit="return toVaild()" class="form-horizontal">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">请选择检测类型：</label>
                                <div class="col-sm-10">
                                    <select class="form-control m-b" id="choice" onchange="choiceItem()" name="type">
                                        <option > -- 请选择 --</option>
                                        <option value="0">产品</option>
                                        <option value="1">原材料</option>
                                    </select>
                                </div>
                            </div>
                        	
                            <div class="form-group">
                                <label class="col-sm-2 control-label">请选择名称：</label>
                                <div class="col-sm-10">
                                    <select class="selectpicker show-tick form-control"
                                            multiple data-max-options="5" data-live-search="true" id="item" name="ids">
                                        <option>请先选择类型</option>
                                    </select>

                                </div>
                            </div>
                        	
                        	
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开始时间：</label>

                                <div class="col-sm-10">
                                    <input type="date" name="beginDate" id="beginDate" class="form-control">
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">结束时间：</label>
                                <div class="col-sm-10">
                                    <input type="date" name="endDate" id="endDate"  class="form-control">
                                </div>
                            </div>
                           
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">查看模式：</label>

                                <div class="col-sm-10">
                                    <label class="checkbox-inline i-checks">
                                         <input type="radio" disabled="disabled" checked="" value="option1"  name="optionsRadios">
                                                                                                                                    列表模式                                                                                            
                                    </label>

                                    <label class="checkbox-inline i-checks">
                                        <input type="radio" disabled="disabled" checked="" value="option1"  name="optionsRadios">
                                                                                                                                    单表模式
                                    </label>

                                    <label class="checkbox-inline i-checks">
                                         <input type="radio" checked="" value="option1"  name="optionsRadios">
                                                                                                                                        全部模式
                                    </label>

                                </div>
                            </div>
                           
                              <div class="form-group">
                                <label class="col-sm-2 control-label">排序模式：</label>

                                <div class="col-sm-10">
                                	
                                	<label class="checkbox-inline i-checks">
                                            <input type="radio" value="option1" checked="checked" name="a"> <i></i> 按检测时间</label>
                                                                                                                                    
                                    </label>
                                	
                                	<label class="checkbox-inline i-checks">
                                            <input type="radio" disabled="disabled" value="option1" name="a"> <i></i> 按检测产品</label>
                                                                                                                                        
                                    </label>
                                	
                                	<label class="checkbox-inline i-checks">
                                            <input type="radio" disabled="disabled" value="option1" name="a"> <i></i> 按录入时间</label>
                                                                                                                                        
                                    </label>
                                	
                                </div>
                            </div>
                            
                             <div class="form-group">
                                <label class="col-sm-2 control-label">查看密码：</label>

                                <div class="col-sm-10">
                                    <input type="password" name="checkPassword" class="form-control">
                                </div>
                            </div>
                           

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                    <!--<button class="btn btn-white" type="submit">取消</button>-->
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

            <div th:include="include::footer"></div>
            <script src="https://cdn.bootcdn.net/ajax/libs/bootstrap-select/2.0.0-beta1/js/bootstrap-select.min.js"></script>

    <script type="text/javascript">
        function choiceItem() {
            var val = $("#choice option:selected").val();
            if(val == 0){
                getProductByUpdate();
            }else if (val == 1){
                getMaterialByUpdate();
//                 $("#item").empty();
            }else{
                $("#item").empty();
            }
        }


        function getProductByUpdate() {
            $("#item").empty();
            $.ajax({
                cache : true,
                type : "GET",
                url : getProjectName()+"/product/getProductList",
                data : $('#signupForm').serialize(),// 你的formid
                async : false,
                error : function(request) {
                    parent.layer.alert("Connection error");
                },
                success : function(data) {
                    var itemList = data.data;
                    var htmlText ="";
                    htmlText += "<option value=''> 请选择 </option>"
                    for (var i in itemList){
                        var item = itemList[i];
                            htmlText += "<option value='"+item.productId+"'> "+item.productName+" </option>"
                    }
                    $("#item").append(htmlText);
                    //使用refresh方法更新UI以匹配新状态。
                    $('#item').selectpicker('refresh');
                    //render方法强制重新渲染引导程序 - 选择ui。
                    $('#item').selectpicker('render');
                }
            });
        }

        function getMaterialByUpdate() {
            $("#item").empty();
            $.ajax({
                cache : true,
                type : "GET",
                url : getProjectName()+"/material/material/getMaterialList",
                data : $('#signupForm').serialize(),// 你的formid
                async : false,
                error : function(request) {
                    parent.layer.alert("Connection error");
                },
                success : function(data) {
                    var itemList = data.data;
                    var htmlText ="";
                    htmlText += "<option value=''> 请选择 </option>"
                    for (var i in itemList){
                        var item = itemList[i];
                            htmlText += "<option value='"+item.materialId+"'> "+item.materialName+" </option>"
                    }
                    $("#item").append(htmlText);
                    //使用refresh方法更新UI以匹配新状态。
                    $('#item').selectpicker('refresh');
                    //render方法强制重新渲染引导程序 - 选择ui。
                    $('#item').selectpicker('render');
                }
            });
        }
        $(function() {
            $(".selectpicker").selectpicker({
                noneSelectedText: '请选择(多选模式)',
                countSelectedText: function(){}
            });
        });

        function toVaild(){
            var val = $("input[name='checkPassword']").val();
            var isPass = false;
             if(!val){
                  layer.msg("请输入密码");
                 return isPass;
             }else{
                 $.ajaxSettings.async = false;
                 $.get(getProjectName()+"/statistics/checkPassword",{password: val},function (isSuccess) {
                     if (!isSuccess) {
                         layer.msg("密码校验错误！");
                     }else {
                         isPass = true;
                         var load = layer.load(1, {shade: false});
                         setTimeout(function () {
                             layer.close(load)
                         },2000)
                     }
                 })
                 $.ajaxSettings.async = true;
                 return isPass;
            }
        }
    </script>

	</body>

</html>